package com.example.testiuh;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class CTDT_Adapter extends ArrayAdapter<CTDT>{
	private  Activity context;
	private int layoutID;
	private ArrayList<CTDT> listCTDT;
	
	public CTDT_Adapter(Activity context, int textViewResourceId,
			ArrayList<CTDT> objects) {
		super(context, textViewResourceId, objects);
		this.context=context;
		this.listCTDT=objects;
		this.layoutID=textViewResourceId;
	}
	public View getView(final int position, View convertView, ViewGroup parent) {	
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		convertView = inflater.inflate(layoutID, null);
		final CTDT ctdt=listCTDT.get(position);
		
		final TextView tvname;
		tvname=(TextView) convertView.findViewById(R.id.txtCTDT);
		tvname.setText(ctdt.getTenNganh());
		tvname.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent mIntent = new Intent(context, TestWeb.class);
				mIntent.putExtra("fileName",ctdt.getFile());
				context.startActivity(mIntent);
			}
		});
		
		return convertView;
	}
}
